home *** CD-ROM | disk | FTP | other *** search
- /* btstack */
- #include <stdio.h>
- #include <btextern.h>
-
- /* stack manipulation routines for the btree system */
-
- #define MAXVAL 50 /* maximum depth of val stack */
-
- static int sp = 0; /* stack pointer */
- static int val[MAXVAL]; /* value stack */
-
- int push (f) /* push f onto value stack */
- int f;
-
- {
- if (sp < MAXVAL)
- return (val[sp++] = f);
- else {
- abort ("ERROR: stack full");
- clear ();
- return (0);
- }
- }
-
- int pop () /* pop top value from stack */
-
- {
- if (sp > 0)
- return (val[--sp]);
- else {
- abort ("ERROR: stack empty");
- clear ();
- return (0);
- }
- }
-
- int clear () /* clear stack */
-
- {
- sp = 0;
- push (NULL);
- push (NULL);
- }